<!DOCTYPE html>
<html lang="en">
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ page isELIgnored="false" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%
	String path = request.getContextPath(); 
    String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<head>
	<title>Moto - FGoods - 编辑</title>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width,minimum-scale=1,maximum-scale=1,user-scalable=no">
    <script type="text/javascript" src="../js/kindeditor-4.1.10/kindeditor.js"></script>
    <script type="text/javascript" src="../js/jquery-1.9.0.min.js"></script>
    <script type="text/javascript" src="../js/layer/layer.js"></script>
    <style type="text/css">
        .body_div{text-align:center;}
        .table-detail{
            text-align:center;
            border: 1px solid rgb(228,228,228);
        }
        th{
            text-align:center;
            background-color: rgb(230,230,230);
            border-bottom: 1px solid rgb(228,228,228);
            font-weight: bold;
            color:rgb(90,90,90);
            padding: 5px 8px;
        }
        td{ text-align:center;border: 1px solid rgb(228,228,228);
            padding: 5px 8px;color:rgb(56,56,56); font-size:15px; width:280px;}
        td input{ width:100%;height:1.5em; line-height:1.5em;}
        a { text-decoration: none; margin:0 1.5em;}
        textarea { width: 100%; resize: none;}
        .imgsc {width:25px;height:25px;}
    </style>
</head>

<body>
<form id="motoForm" name="motoForm" action="<%=basePath%>fgoods/edit" method="post" enctype="multipart/form-data">
<div class="body_div" >
    <input type="hidden" name = "id" value="${SRModel.id}"/>
    <input type="hidden" id = "status" name = "status" value="${SRModel.status}"/>
    <input type="hidden" id = "img_url1" name = "img_url1" value="${SRModel.img_url1}"/>
    <input type="hidden" id = "img_url2" name = "img_url2" value="${SRModel.img_url2}"/>
    <input type="hidden" id = "img_url3" name = "img_url3" value="${SRModel.img_url3}"/>
    <input type="hidden" id = "img_url4" name = "img_url4" value="${SRModel.img_url4}"/>
    <input type="hidden" id = "img_url5" name = "img_url5" value="${SRModel.img_url5}"/>
    <table class="table-detail" align="center">
        <tr>
            <td colspan="4" >
                <strong>编辑 - ${SRModel.goodsname}</strong>
            </td>
        </tr>
        <tr>
            <th>配件名称</th>
            <td colspan="3"><input name="goodsname" value="${SRModel.goodsname}"/></td>
        </tr>
        <tr>
            <th>配件主型</th>
            <td colspan=""><input name="goodstype" value="${SRModel.goodstype}"/></td>
            <th>配件子类</th>
            <td colspan=""><input name="goodstwotype" value="${SRModel.goodstwotype}"/></td>
        </tr>
        <tr>
            <th>品牌</th>
            <td colspan=""><input name="goodsbrand" value="${SRModel.goodsbrand}"/></td>
            <th>型号</th>
            <td colspan=""><input name="goodsmodel" value="${SRModel.goodsmodel}"/></td>
        </tr>

        <tr>
            <th>省</th>
            <td><input name="province" value="${SRModel.province}"/></td>
            <th>区域</th>
            <td><input name="city" value="${SRModel.city}"/></td>
        </tr>
        <tr>
            <th>门店/公司</th>
            <td  colspan="3"><input name="nick" value="${SRModel.nick}"/></td>
        </tr>
        <tr>
            <th>url路径</th>
            <%--<td colspan=""><input name="url" value="${SRModel.url}"/></td>--%>
            <td colspan="3" style="float:left;">
                <a href="${SRModel.url}" target="_blank" style="width:100%;">${SRModel.url}</a>
            </td>
        </tr>
        <tr>
            <th>价格</th>
            <td><input name="price" value="${SRModel.price}"/></td>
            <th>原价</th>
            <td><input name="orgprice" value="${SRModel.orgprice}"/></td>
        </tr>
        <tr>
            <th>货币</th>
            <td ><input name="currency" value="${SRModel.currency}"/></td>
            <th>分数</th>
            <td ><input name="score" value="${SRModel.score}"/></td>
        </tr>
        <tr>
            <th>配件说明</th>
            <td colspan="3"><textarea rows="8" name="atrrs"  >${SRModel.atrrs}</textarea> </td>
        </tr>
        <tr>
            <th>内容</th>
            <td colspan="3"><textarea rows="38" id="content" name="content" >${SRModel.content}</textarea> </td>
        </tr>

        <tr>
            <th>图片1</th>
            <td >
                <input type="file" value="选择图片" id="img_1" name="img_1"/>
            </td>
            <td style="vertical-align: middle;">
                <c:if test="${SRModel.img_url1 !=null and SRModel.img_url1!=''}">
                    <a href="<%=basePath%>${SRModel.img_url1}" target="_blank">
                        <img class="imgsc" id="imgPath1" src="<%=basePath%>${SRModel.img_url1}"/>
                    </a>
                </c:if>
            </td>
            <td>
                <c:if test="${SRModel.img_url1 !=null and SRModel.img_url1!=''}">
                        <a id="delImg1" href="javascript:ajaxDelImg(1,'${SRModel.img_url1}');">删除</a>
                </c:if>
            </td>
        </tr>
        <tr>
            <th>图片2</th>
            <td colspan=""> <input type="file" value="选择图片" id="img_2" name="img_2"/></td>
            <td>
                <c:if test="${SRModel.img_url2 !=null and SRModel.img_url2!=''}">
                    <a href="<%=basePath%>${SRModel.img_url2}" target="_blank">
                        <img class="imgsc" id="imgPath2" src="<%=basePath%>${SRModel.img_url2}"/>
                    </a>
                </c:if>
            </td>
            <td>
                <c:if test="${SRModel.img_url2 !=null and SRModel.img_url2!=''}">
                        <a id="delImg2" href="javascript:ajaxDelImg(2,'${SRModel.img_url2}');">删除</a>
                </c:if>
            </td>
        </tr>
        <tr>
            <th>图片3</th>
            <td colspan=""> <input type="file" value="选择图片" id="img_3" name="img_3"/></td>
            <td>
                <c:if test="${SRModel.img_url3 !=null and SRModel.img_url3!=''}">
                    <a href="<%=basePath%>${SRModel.img_url3}" target="_blank">
                        <img class="imgsc" id="imgPath3" src="<%=basePath%>${SRModel.img_url3}"/>
                    </a>
                </c:if>
            </td>
            <td>
                <c:if test="${SRModel.img_url3 !=null and SRModel.img_url3!=''}">
                    <a id="delImg3" href="javascript:ajaxDelImg(3,'${SRModel.img_url3}');">删除</a>
                </c:if>
            </td>
        </tr>
        <tr>
            <th>图片4</th>
            <td colspan=""> <input type="file" value="选择图片" id="img_4" name="img_4"/></td>
            <td>
               <c:if test="${SRModel.img_url4 !=null and SRModel.img_url4!=''}">
                   <a href="<%=basePath%>${SRModel.img_url4}" target="_blank">
                        <img class="imgsc" id="imgPath4"  src="<%=basePath%>${SRModel.img_url4}"/>
                   </a>
               </c:if>
            </td>
            <td>
               <c:if test="${SRModel.img_url4 !=null and SRModel.img_url4!=''}">
                   <a id="delImg4" href="javascript:ajaxDelImg(4,'${SRModel.img_url4}');">删除</a>
               </c:if>
            </td>
        </tr>
        <tr>
            <th>图片5</th>
            <td colspan=""> <input type="file" value="选择图片" id="img_5" name="img_5"/></td>
            <td>
                <c:if test="${SRModel.img_url5 !=null and SRModel.img_url5!=''}">
                    <a href="<%=basePath%>${SRModel.img_url5}" target="_blank">
                        <img class="imgsc" id="imgPath5" src="<%=basePath%>${SRModel.img_url5}"/>
                    </a>
                </c:if>
            </td>
            <td>
                <c:if test="${SRModel.img_url5 !=null and SRModel.img_url5!=''}">
                  <a id="delImg5" href="javascript:ajaxDelImg(5,'${SRModel.img_url5}');">删除</a>
                 </c:if>
            </td>
        </tr>

        <tr>
            <td colspan="4">
                <a href="javascript:ajaxUpFgoodsStatus();">[确认]</a>
                <a href="javascript:editSaveFgoods();">[保存]</a>
                <a href="javascript:window.close();">[关闭]</a>
                <%--<a href="javascript:history.go(-1);">[返回]</a>--%>
            </td>
        </tr>

    </table>
</div>

</form>
</body>
<script type="text/javascript">
    window.onload=function(){
        var upFlag = "${upFlag}";
        if(upFlag){
            window.opener.location.reload();
            layer.msg("保存成功!");
//            if(confirm("保存成功!是否关闭？")){
//                window.close();
//            }
        }

    };

    function editSaveFgoods(){
        document.motoForm.action ="<%=basePath%>fgoods/editsave";
        document.motoForm.submit();
    }

    function upFgoodsStatus(){
        document.getElementById("status").value = 1;
        document.motoForm.action ="<%=basePath%>/upfgoods/status";
        document.motoForm.submit();
    }

    function ajaxUpFgoodsStatus(){
        var tid = "${SRModel.id}";
        if(!confirm("确定标志为操作?")){
            return ;
        }

        $.ajax({
            type:"POST",
            url:"<%=basePath%>ajax/upfgoods/status",
            data:{
                'id' : tid,
                'status' : "1",
                'tm':new Date().getTime()
            },
            dataType:'json',
            cache: false,
            async: false,
            success: function(data){
                if(data.code==0){
                   layer.msg("操作成功");
                }
            }, error: function(XMLHttpRequest, textStatus, errorThrown) {
                layer.msg(XMLHttpRequest.status+" | "+XMLHttpRequest.readyState+"|"+textStatus);
            }
        });
    }

    var editor;
    KindEditor.ready(function(K) {
        editor= K.create('textarea[name="content"]', {
            uploadJson : '<%=basePath %>/js/kindeditor-4.1.10/jsp/upload_json.jsp',
            fileManagerJson : '<%=basePath %>/js/kindeditor-4.1.10/jsp/file_manager_json.jsp',
            allowFileManager : true,
            allowImageUpload : true,
            autoHeightMode : true,
            afterCreate : function() {this.loadPlugin('autoheight');},
            afterBlur : function(){ this.sync(); }  //Kindeditor下获取文本框信息
        });
    });
   /* KindEditor.ready(function(K) {
        editor = K.create('#content');
    });
    var options = {
        cssPath : '/css/index.css',
        filterMode : true,
        uploadJson : '<%=basePath %>/js/kindeditor-4.1.10/jsp/upload_json.jsp',
        fileManagerJson : '<%=basePath %>/js/kindeditor-4.1.10/jsp/file_manager_json.jsp',
        allowFileManager : true,
        allowImageUpload : true,
        autoHeightMode : true,
        afterCreate : function() {this.loadPlugin('autoheight');},
        afterBlur : function(){ this.sync(); }  //Kindeditor下获取文本框信息
    };
    var editor = K.create('textarea[name="content"]', options);
   */
    function ajaxDelImg(uidx,urlPath){
        if(!confirm("确定删除当前图片?")){
            return ;
        }
        $.ajax({
            type:"POST",
            url:"<%=basePath%>ajax/del/img",
            data:{
                'id' : "${SRModel.id}",
                'uidx' : uidx,
                'urlPath' : urlPath,
                'tm':new Date().getTime()
            },
            dataType:'json',
            cache: false,
            async: false,
            success: function(data){
                if(data.code==0){
                    layer.msg("删除成功");
                    $("#delImg"+uidx).hide();
                    $("#imgPath"+uidx).hide();
                }
            }, error: function(XMLHttpRequest, textStatus, errorThrown) {
                alert(XMLHttpRequest.status+" | "+XMLHttpRequest.readyState+"|"+textStatus);
            }
        });
    }

</script>
</html> 

